<?php
/**
 * Here is your custom functions.
 */

use support\Container;
use app\utils\Json;
use think\Collection;
use Webman\Http\Response;

if (!function_exists('success')) {
    /**
     * Json 成功响应
     * @param $msg
     * @param array|Collection|string|null $data
     * @return Response
     */
    function success($msg = 'ok', array|Collection|string|null $data = null): Response
    {
        return Container::get(Json::class)->success($msg, $data);
    }
}


if (!function_exists('fail')) {
    /**
     * Json 失败响应
     * @param $msg
     * @param array|null $data
     * @return Response
     */
    function fail($msg = 'fail', ?array $data = null): Response
    {
        return Container::get(Json::class)->fail($msg, $data);
    }
}


